package com.prize.controller;

import com.prize.dtos.MemberUserDto;
import com.prize.dtos.ResponseResult;
import com.prize.members.apis.MemberControllerApi;
import com.prize.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = {"会员管理：会员管理控制类"})
@RestController
@RequestMapping("/api/v1/member")
public class MemberController implements MemberControllerApi {

    @Autowired
    private MemberService memberService;


    @ApiOperation(value = "会员列表")
    @PostMapping("/getMembers")
    public ResponseResult getMembers(@RequestBody MemberUserDto cardUserDto) {
        return this.memberService.getMembers(cardUserDto);
    }

    @ApiOperation(value = "新增会员")
    @PostMapping("/addMember")
    public ResponseResult addMembers(@RequestBody MemberUserDto cardUser) {
        return this.memberService.addMembers(cardUser);
    }

    @ApiOperation(value = "修改会员")
    @PostMapping("/upMember")
    public ResponseResult upMembers(@RequestBody MemberUserDto cardUser) {
        return this.memberService.upMembers(cardUser);
    }

    @ApiOperation(value = "删除会员")
    @GetMapping("/delMembers/{id}")
    public ResponseResult delMembers(@PathVariable String id) {
        return this.memberService.delMembers(id);
    }

    @ApiOperation(value = "根据id查询会员")
    @GetMapping("/members/{id}")
    public ResponseResult getmembersId(@PathVariable Integer id) {
        return this.memberService.getmembersId(id);
    }
}
